<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: ApplicationController</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">ApplicationController</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/app/controllers/application_rb.html">
                app/controllers/application.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                ActionController::Base
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Filters added to this controller apply to all controllers in the
application. Likewise, all the methods added will be available for all
controllers.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000134">configure_charsets</a>&nbsp;&nbsp;
      <a href="#M000136">filtra_eventos</a>&nbsp;&nbsp;
      <a href="#M000135">paginate_by_sql</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000134" class="method-detail">
        <a name="M000134"></a>

        <div class="method-heading">
          <a href="#M000134" class="method-signature">
          <span class="method-name">configure_charsets</span><span class="method-args">(charset='UTF-8')</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Define o charset default da aplicação
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000134-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000134-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/application.rb, line 9</span>
 9:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure_charsets</span>(<span class="ruby-identifier">charset</span>=<span class="ruby-value str">'UTF-8'</span>)
10:     <span class="ruby-identifier">suppress</span>(<span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">StatementInvalid</span>) <span class="ruby-keyword kw">do</span>
11:       <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">connection</span>.<span class="ruby-identifier">execute</span> <span class="ruby-value str">&quot;SET NAMES 'UTF8'&quot;</span>
12:     <span class="ruby-keyword kw">end</span>
13:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000136" class="method-detail">
        <a name="M000136"></a>

        <div class="method-heading">
          <a href="#M000136" class="method-signature">
          <span class="method-name">filtra_eventos</span><span class="method-args">(eventos)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
filtra os eventos por perfil
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000136-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000136-source">
<pre>
     <span class="ruby-comment cmt"># File app/controllers/application.rb, line 54</span>
 54:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">filtra_eventos</span>(<span class="ruby-identifier">eventos</span>)
 55:     <span class="ruby-comment cmt">#### Ações permitidas a cada perfil #########</span>
 56:     <span class="ruby-identifier">analista</span> = [<span class="ruby-value str">&quot;enviarParaDesenvolvimento&quot;</span>,
 57:                 <span class="ruby-value str">&quot;enviarParaAtualizacaoProducao&quot;</span>, 
 58:                 <span class="ruby-value str">&quot;enviarParaCertificacao&quot;</span>,
 59:                 <span class="ruby-value str">&quot;reprovarDesenvolvimentoAnalista&quot;</span>,
 60:                 <span class="ruby-value str">&quot;aprovarDesenvolvimentoAnalista&quot;</span>,
 61:                 <span class="ruby-value str">&quot;solicitarAtualizacaoServidorProd&quot;</span>,
 62:                 <span class="ruby-value str">&quot;solicitarAtualizacaoBdProd&quot;</span>]
 63:     <span class="ruby-identifier">desenvolvedor</span> = [<span class="ruby-value str">&quot;iniciarDesenvolvimento&quot;</span>,
 64:                      <span class="ruby-value str">&quot;suspenderDesenvolvimento&quot;</span>,
 65:                      <span class="ruby-value str">&quot;concluirDesenvolvimento&quot;</span>]
 66:     <span class="ruby-identifier">certificador</span> = [<span class="ruby-value str">&quot;iniciarCertificacao&quot;</span>,
 67:                     <span class="ruby-value str">&quot;reprovarRequisicao&quot;</span>,
 68:                     <span class="ruby-value str">&quot;solicitarAtualizacaoServidorCert&quot;</span>,
 69:                     <span class="ruby-value str">&quot;solicitarAtualizacaoBdCert&quot;</span>,
 70:                     <span class="ruby-value str">&quot;aprovarRequisicao&quot;</span>,
 71:                     <span class="ruby-value str">&quot;suspenderCertificacao&quot;</span>]
 72:     <span class="ruby-identifier">pool</span> = [<span class="ruby-value str">&quot;escalarDesenvolvedor&quot;</span>,
 73:             <span class="ruby-value str">&quot;reprovarDesenvolvimento&quot;</span>,
 74:             <span class="ruby-value str">&quot;aprovarDesenvolvimento&quot;</span>,
 75:             <span class="ruby-value str">&quot;iniciarDesenvolvimento&quot;</span>,
 76:             <span class="ruby-value str">&quot;suspenderDesenvolvimento&quot;</span>,
 77:             <span class="ruby-value str">&quot;concluirDesenvolvimento&quot;</span>]
 78:     
 79:     <span class="ruby-identifier">certificacao</span> = [<span class="ruby-value str">&quot;escalarCertificador&quot;</span>,
 80:                   <span class="ruby-value str">&quot;solicitarAtualizacaoBdCert&quot;</span>,
 81:                   <span class="ruby-value str">&quot;cancelarCert&quot;</span>,
 82:                   <span class="ruby-value str">&quot;solicitarAtualizacaoServidorCert&quot;</span>]
 83:     <span class="ruby-identifier">gerente</span>  = [<span class="ruby-value str">&quot;autorizarAtualizacao&quot;</span>]
 84:     <span class="ruby-identifier">banco</span> = [<span class="ruby-value str">&quot;cancelarAtualizacaoBdCert&quot;</span>,
 85:             <span class="ruby-value str">&quot;iniciarAtualizacaoBdCert&quot;</span>,
 86:             <span class="ruby-value str">&quot;suspenderAtualizacaoBdCert&quot;</span>,
 87:             <span class="ruby-value str">&quot;concluirAtualizacaoBdCert&quot;</span>,
 88:             <span class="ruby-value str">&quot;iniciarAtualizacaoBdProd&quot;</span>,
 89:             <span class="ruby-value str">&quot;suspenderAtualizacaoBdProd&quot;</span>,
 90:             <span class="ruby-value str">&quot;cancelarAtualizacaoBdProd&quot;</span>,
 91:             <span class="ruby-value str">&quot;concluirAtulizacaoBdProd&quot;</span>]
 92:     <span class="ruby-identifier">suporte</span> = [<span class="ruby-value str">&quot;iniciarAtualizacaoServidorCert&quot;</span>,
 93:               <span class="ruby-value str">&quot;cancelarAtualizacaoServidorCert&quot;</span>,
 94:               <span class="ruby-value str">&quot;suspenderAtualizacaoServidorCert&quot;</span>,
 95:               <span class="ruby-value str">&quot;concluirAtualizacaoServidorCert&quot;</span>,
 96:               <span class="ruby-value str">&quot;iniciarAtualizacaoServidorProd&quot;</span>,
 97:               <span class="ruby-value str">&quot;suspenderAtualizacaoServidorProd&quot;</span>,
 98:               <span class="ruby-value str">&quot;cancelarAtualizacaoServidorProd&quot;</span>,
 99:               <span class="ruby-value str">&quot;concluirAtulizacaoServidorProd&quot;</span>]
100:     <span class="ruby-identifier">producao</span> = [<span class="ruby-value str">&quot;solicitarAtualizacaoBdProd&quot;</span>,
101:             <span class="ruby-value str">&quot;solicitarAtualizacaoServidorProd&quot;</span>,
102:             <span class="ruby-value str">&quot;reportarErroProducao&quot;</span>,
103:             <span class="ruby-value str">&quot;autorizaEnvioProd&quot;</span>]
104:     
105:     <span class="ruby-identifier">tecnico</span> = [<span class="ruby-value str">&quot;solicitarAtualizacaoBdProd&quot;</span>,
106:             <span class="ruby-value str">&quot;solicitarAtualizacaoServidorProd&quot;</span>,
107:             <span class="ruby-value str">&quot;reportarErroProducao&quot;</span>]   
108:     <span class="ruby-comment cmt">#############################################  </span>
109:     <span class="ruby-identifier">ret</span> = []
110:     <span class="ruby-identifier">user</span> = <span class="ruby-constant">Goldberg</span>.<span class="ruby-identifier">user</span>.<span class="ruby-identifier">role_id</span>  
111:     <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Goldberg</span>.<span class="ruby-identifier">user</span>.<span class="ruby-identifier">role_id</span> <span class="ruby-operator">==</span> <span class="ruby-value">4</span>
112:       <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">e</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">eventos</span>
113:         <span class="ruby-identifier">analista</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>
114:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">a</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>
115:             <span class="ruby-identifier">ret</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">e</span>
116:           <span class="ruby-keyword kw">end</span>
117:         <span class="ruby-keyword kw">end</span>
118:       <span class="ruby-keyword kw">end</span>
119:     <span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">Goldberg</span>.<span class="ruby-identifier">user</span>.<span class="ruby-identifier">role_id</span> <span class="ruby-operator">==</span> <span class="ruby-value">10</span>
120:       <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">e</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">eventos</span>
121:         <span class="ruby-identifier">certificador</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>
122:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">a</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>
123:             <span class="ruby-identifier">ret</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">e</span>
124:           <span class="ruby-keyword kw">end</span>
125:         <span class="ruby-keyword kw">end</span>
126:       <span class="ruby-keyword kw">end</span>
127:       
128:     <span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">Goldberg</span>.<span class="ruby-identifier">user</span>.<span class="ruby-identifier">role_id</span> <span class="ruby-operator">==</span> <span class="ruby-value">14</span> 
129:       <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">e</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">eventos</span>
130:         <span class="ruby-identifier">pool</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>
131:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">a</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>
132:             <span class="ruby-identifier">ret</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">e</span>
133:           <span class="ruby-keyword kw">end</span>
134:         <span class="ruby-keyword kw">end</span>
135:       <span class="ruby-keyword kw">end</span>
136:     <span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">Goldberg</span>.<span class="ruby-identifier">user</span>.<span class="ruby-identifier">role_id</span> <span class="ruby-operator">==</span> <span class="ruby-value">5</span> 
137:       <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">e</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">eventos</span>
138:         <span class="ruby-identifier">desenvolvedor</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>
139:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">a</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>
140:             <span class="ruby-identifier">ret</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">e</span>
141:           <span class="ruby-keyword kw">end</span>
142:         <span class="ruby-keyword kw">end</span>
143:       <span class="ruby-keyword kw">end</span>
144:     <span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">Goldberg</span>.<span class="ruby-identifier">user</span>.<span class="ruby-identifier">role_id</span> <span class="ruby-operator">==</span> <span class="ruby-value">13</span> 
145:       <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">e</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">eventos</span>
146:         <span class="ruby-identifier">certificacao</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>
147:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">a</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>
148:             <span class="ruby-identifier">ret</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">e</span>
149:           <span class="ruby-keyword kw">end</span>
150:         <span class="ruby-keyword kw">end</span>
151:       <span class="ruby-keyword kw">end</span>
152:     <span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">Goldberg</span>.<span class="ruby-identifier">user</span>.<span class="ruby-identifier">role_id</span> <span class="ruby-operator">==</span> <span class="ruby-value">11</span> 
153:       <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">e</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">eventos</span>
154:         <span class="ruby-identifier">banco</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>
155:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">a</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>
156:             <span class="ruby-identifier">ret</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">e</span>
157:           <span class="ruby-keyword kw">end</span>
158:         <span class="ruby-keyword kw">end</span>
159:       <span class="ruby-keyword kw">end</span>
160:     <span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">Goldberg</span>.<span class="ruby-identifier">user</span>.<span class="ruby-identifier">role_id</span> <span class="ruby-operator">==</span><span class="ruby-value">12</span> 
161:       <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">e</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">eventos</span>
162:         <span class="ruby-identifier">suporte</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>
163:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">a</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>
164:             <span class="ruby-identifier">ret</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">e</span>
165:           <span class="ruby-keyword kw">end</span>
166:         <span class="ruby-keyword kw">end</span>
167:       <span class="ruby-keyword kw">end</span>
168:     <span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">Goldberg</span>.<span class="ruby-identifier">user</span>.<span class="ruby-identifier">role_id</span> <span class="ruby-operator">==</span> <span class="ruby-value">8</span> 
169:       <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">e</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">eventos</span>
170:         <span class="ruby-identifier">producao</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>
171:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">a</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>
172:             <span class="ruby-identifier">ret</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">e</span>
173:           <span class="ruby-keyword kw">end</span>
174:         <span class="ruby-keyword kw">end</span>
175:       <span class="ruby-keyword kw">end</span>
176:     <span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">Goldberg</span>.<span class="ruby-identifier">user</span>.<span class="ruby-identifier">role_id</span> <span class="ruby-operator">==</span> <span class="ruby-value">9</span>
177:       <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">e</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">eventos</span>
178:         <span class="ruby-identifier">tecnico</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>
179:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">a</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>
180:             <span class="ruby-identifier">ret</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">e</span>
181:           <span class="ruby-keyword kw">end</span>
182:         <span class="ruby-keyword kw">end</span>
183:       <span class="ruby-keyword kw">end</span> 
184:     <span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">Goldberg</span>.<span class="ruby-identifier">user</span>.<span class="ruby-identifier">role_id</span> <span class="ruby-operator">==</span> <span class="ruby-value">7</span> 
185:       <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">e</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">eventos</span>
186:         <span class="ruby-identifier">gerente</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>
187:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">a</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>
188:             <span class="ruby-identifier">ret</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">e</span>
189:           <span class="ruby-keyword kw">end</span>
190:         <span class="ruby-keyword kw">end</span>
191:       <span class="ruby-keyword kw">end</span>  
192:     <span class="ruby-keyword kw">end</span>
193:     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">ret</span>.<span class="ruby-identifier">empty?</span>
194:       <span class="ruby-keyword kw">return</span> <span class="ruby-value str">&quot;&quot;</span>
195:     <span class="ruby-keyword kw">else</span>
196:       <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">ret</span>
197:     <span class="ruby-keyword kw">end</span>
198:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000135" class="method-detail">
        <a name="M000135"></a>

        <div class="method-heading">
          <a href="#M000135" class="method-signature">
          <span class="method-name">paginate_by_sql</span><span class="method-args">(model, sql, per_page, options={})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000135-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000135-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/application.rb, line 36</span>
36:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">paginate_by_sql</span>(<span class="ruby-identifier">model</span>, <span class="ruby-identifier">sql</span>, <span class="ruby-identifier">per_page</span>, <span class="ruby-identifier">options</span>={})
37:     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:count</span>]
38:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:count</span>].<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Integer</span>
39:         <span class="ruby-identifier">total</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:count</span>]
40:       <span class="ruby-keyword kw">else</span>
41:         <span class="ruby-identifier">total</span> = <span class="ruby-identifier">model</span>.<span class="ruby-identifier">count_by_sql</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:count</span>])
42:       <span class="ruby-keyword kw">end</span>
43:     <span class="ruby-keyword kw">else</span>
44:       <span class="ruby-identifier">total</span> = <span class="ruby-identifier">model</span>.<span class="ruby-identifier">count_by_sql_wrapping_select_query</span>(<span class="ruby-identifier">sql</span>)
45:     <span class="ruby-keyword kw">end</span>
46:     
47:     <span class="ruby-identifier">object_pages</span> = <span class="ruby-constant">Paginator</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">total</span>, <span class="ruby-identifier">per_page</span>, <span class="ruby-identifier">params</span>[<span class="ruby-value str">'page'</span>]
48:     <span class="ruby-identifier">objects</span> = <span class="ruby-identifier">model</span>.<span class="ruby-identifier">find_by_sql_with_limit</span>(<span class="ruby-identifier">sql</span>,
49:                                            <span class="ruby-identifier">object_pages</span>.<span class="ruby-identifier">current</span>.<span class="ruby-identifier">to_sql</span>[<span class="ruby-value">1</span>], <span class="ruby-identifier">per_page</span>)
50:     <span class="ruby-keyword kw">return</span> [<span class="ruby-identifier">object_pages</span>, <span class="ruby-identifier">objects</span>]
51:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>